/*
 * exceptions.hpp
 *
 *  Created on: Apr 7, 2013
 *      Author: nick
 */

#ifndef EXCEPTIONS_HPP_
#define EXCEPTIONS_HPP_

#include <exception>
#include <string>
#include <cstring>
#include <cerrno>

class NamedException : public std::exception {
private:
	std::string message;
public:
	NamedException(const std::string & name, const std::string & message) : message(name) {
		(this->message += " : ") += message;
		if(errno != 0) {
			(this->message += ". Error : ") += strerror(errno);
		}
	}

	virtual const char* what() const throw() {
		return message.c_str();
	}

	virtual ~NamedException() throw() {}
};

class NotImplementedException : public NamedException {
public:
	NotImplementedException(const std::string & message) : NamedException("NotImplementedException", message) {}
};

class IOException : public NamedException {
public:
	IOException(const std::string & message) : NamedException("IOException", message) {}
};

class ParseException : public NamedException {
public:
	ParseException(const std::string & message) : NamedException("ParseException", message) {}
};
#endif /* EXCEPTIONS_HPP_ */
